﻿@model CREAPA.Dominio.FuncionarioSetor

@{
    ViewBag.Title = "Lista de Setores";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<style type="text/css">
.table{
    border : 1px solid #809FFF;
    background-color: white;
    
    border-collapse: collapse; 
    border: 1px solid black; 
}

.header{
    background-color: #111839;
    color: white;
}

.header a{
    color: white;
    text-decoration: none;
}

.footer{
    background-color:#111839;
    color: white;
}

.alternate{
    background-color: #b7c3f6;
}
</style>

@{    
    var gridSetor = new WebGrid(ViewBag.listaFuncionarioSetor, canPage: true, rowsPerPage: 100);
}

@{    
    var gridSetorDisponivel = new WebGrid(ViewBag.listaFuncionarioSetorDisponivel, canPage: true, rowsPerPage: 100);
}

<div id="content">
@using (Html.BeginForm("Excluir","FuncionarioSetor")) {
    @Html.AntiForgeryToken()

@Html.HiddenFor(model => model.Login)

@Html.ValidationSummary(true)
<h2>Lista de Setores Do Usuario</h2>

    @gridSetor.GetHtml( tableStyle: "table",
        alternatingRowStyle: "alternate",
        headerStyle: "header",
        footerStyle: "footer",
        mode: WebGridPagerModes.FirstLast | WebGridPagerModes.NextPrevious,
        firstText: "Primeiro",
        previousText: "Anterior",
        nextText: "Próximo",
        lastText: "Último",columns: gridSetor.Columns(
            gridSetor.Column("Id", header:"Setor", format: @<text><center>@item.Id</center></text>),                 
            gridSetor.Column("Setor", header:"Nome do Setor", format: @<text>@item.Setor</text>),
            gridSetor.Column(header: "Excluir",   format: @<text><center><input name="Excluir" type="checkbox" value="@item.Id"/></center></text>)
           )
)          
        <p> 
        <input type="submit" value="Excluir" class="button"/>
        </p>
}
</div>
@using (Html.BeginForm("Adicionar","FuncionarioSetor")) {
    @Html.AntiForgeryToken()
<h2>Lista de Setores Disponiveis Para o Usuario</h2>

@gridSetorDisponivel.GetHtml( tableStyle: "table",
        alternatingRowStyle: "alternate",
        headerStyle: "header",
        footerStyle: "footer",
        mode: WebGridPagerModes.FirstLast | WebGridPagerModes.NextPrevious,
        firstText: "Primeiro",
        previousText: "Anterior",
        nextText: "Próximo",
        lastText: "Último",columns: gridSetorDisponivel.Columns(
            gridSetorDisponivel.Column("Id", header:"Setor", format: @<text><center>@item.Id</center></text>),                 
            gridSetorDisponivel.Column("Setor", header:"Nome do Setor", format: @<text>@item.Setor</text>),
            gridSetorDisponivel.Column(header:"Adicionar", format: @<text><center><input name="Selecionar" type="checkbox" value="@item.Id"/></center></text>)
        )
)
          <p>
            <input type="submit" value="Adicionar" class="button"/>
            @Html.ActionLink("Voltar", "Alterar","Funcionario", new {login = ViewBag.Login},new { @class = "button2"})
      </p>
}   

<script src="~/Scripts/TabelBackgroundColor.js"></script>
<script>
    $(document).ready(function () {
        $("#content tbody tr").each(function (i, Column) {
            var priceToday = $(this).find("td:nth-child(2)").html();

            //check if its greater than zero
            if (priceToday.indexOf("SETOR PRINCIPAL") != -1) {
                $(this).find("td:nth-child(3)").empty();
            }
        });
    });
</script>

